package com.shop2cn.iapi.agentproducts.testcase;

import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.shop2cn.iapi.agentproducts.parameter.*;
import com.shop2cn.iapi.agentproducts.service.QueryAgentPriceChainCall;
import com.ymatou.iapi.dguser.parameter.UserCreateBean;
import com.ymatou.iapi.godmch.parameter.CreateCodeBean;
import com.ymatou.iapi.godmch.parameter.applyAgentBean;
import com.ymatou.iapi.godmch.parameter.createDepotBean;
import com.ymatou.iapi.godmch.parameter.createIndepMchBean;
import com.ymatou.iapi.godmch.parameter.createagentBean;
import com.ymatou.iapi.godmch.parameter.createmchBean;
import com.ymatou.iapi.godmch.service.CreateCodeCall;
import com.ymatou.iapi.godmch.service.createIndepMchCall;
import com.ymatou.iapi.godmch.service.createagentCall;
import com.ymatou.iapi.prodstock.parameter.AgentProductPo;
import com.ymatou.iapi.productmanager.parameter.GetProductCatalogInfosBean;
import com.ymatou.iapi.productmanager.service.GetProductCatalogInfosCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymttest.business.service.AddAgentProductCallService;
import com.ymttest.business.service.AgentProductCallService;
import com.ymttest.business.service.DGUserCallService;
import com.ymttest.business.service.shenqi.GodmchManageCallService;
import com.ymttest.database.model.YmtCatalogsI;
import com.ymttest.database.model.YmtProductsI;
import com.ymttest.database.model.agent_type;
import com.ymttest.database.model.godmch.mch_depot_info;
import com.ymttest.database.sqlwapper.YmtCatalogsIWapper;
import com.ymttest.database.sqlwapper.YmtProductsIWapper;
import com.ymttest.database.sqlwapper.godmch.agent_typeWapper;
import com.ymttest.database.sqlwapper.godmch.mch_relationWapper;
import com.ymttest.utils.AgentUsers;
import com.ymttest.utils.MapUtil;

import org.junit.*;
import org.junit.experimental.categories.Category;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
*查询代理商品价格链
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_QueryAgentPriceChain{
	private static QueryAgentPriceChainBean queryagentpricechainBean;
	private static QueryAgentPriceChainCall queryagentpricechainCall;
	private static YmtCatalogsIWapper ymtCatalogsIWapper = new YmtCatalogsIWapper();
	private static YmtProductsIWapper ymtProductsIWapper = new YmtProductsIWapper();
	public  agent_typeWapper agentTypeWapper=new agent_typeWapper();
	//渠道商
	private static int sellerId = AgentUsers.rootUserId;
	private static String sellerName = "NickautoTest";
	//渠道商->代理商1
	private static int agentUserId1 = AgentUsers.agentUserId1;
	private static String agentUserName1 = "NickautoTest";
	//渠道商->代理商2
	private static int agentUserId2 = AgentUsers.agentUserId2;
	private static String agentUserName2 = "NickautoTest";
	//vip渠道
	private static int vipRootUserId = AgentUsers.vipRootUserId;
	private static String vipRootUserName = "NickautoTest";
	//vip渠道->代理1
	private static int vipAgentUserId1 = AgentUsers.vipAgentUserId1;
	private static String vipAgentUserName1 = "dgsq408897016";
	//vip渠道->代理1->代理2
	private static int vipAgentUserId2 = AgentUsers.vipAgentUserId2;
	private static String vipAgentUserName2 = "NickautoTest";
	//vip渠道->代理1->代理3
	private static int vipAgentUserId3 = 500018937;
	private static String vipAgentUserName3 = "NickautoTest";
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("查询代理商品价格链");
	}

	@Before
	public void caseUp() {
		queryagentpricechainBean=new QueryAgentPriceChainBean();
		queryagentpricechainCall=new QueryAgentPriceChainCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(queryagentpricechainCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}


	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QueryAgentPriceChain_01() {
		Logger.start(true,"渠道商查询自采商品价格,查询失败");
		try {
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId,sellerName,true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			List<String> catalogIds = new ArrayList<>();
			ymtCatalogsIWapper.selectCatalogsByProductId(productId).forEach(p->{
				catalogIds.add(p.getsCatalogId());
			});
			queryagentpricechainBean.setCatalogIds(catalogIds);
			queryagentpricechainCall.setData(queryagentpricechainBean);
			queryagentpricechainCall.callService();			
			Logger.verifyEquals("201",queryagentpricechainCall.getString("code"),"验证code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QueryAgentPriceChain_02() {
		Logger.start(true,"普通代理查询代理商品价格链，查询成功");
		try {
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(sellerId,sellerName,true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService.initImportAgentProduct(agentUserId1,agentUserName1,productId,sellerId,false);
			String agentProductId = AddAgentProductCallService.ImportAgentProduct(importAgentProductBean);
			List<String> catalogIds = new ArrayList<>();
			ymtCatalogsIWapper.selectCatalogsByProductId(agentProductId).forEach(p->{
				catalogIds.add(p.getsCatalogId());
			});
			queryagentpricechainBean.setCatalogIds(catalogIds);
			queryagentpricechainCall.setData(queryagentpricechainBean);
			queryagentpricechainCall.callService();
			Logger.verifyEquals("200",queryagentpricechainCall.getString("code"),"验证规格");
			HashMap<String, List<CatalogLinkedMapDto>> result = queryagentpricechainCall.getResult();

            catalogIds.forEach(p->{
                result.get(p).forEach(x->{
                    try {
                        YmtCatalogsI ymtCatalogsI = ymtCatalogsIWapper.selectCatalogsByCatalogId(p);
                        YmtCatalogsI ymtCatalogsI1 = ymtCatalogsIWapper.selectCatalogsByCatalogId(ymtCatalogsI.getRootCatalogId());

                        AgentProductPo agentProductPo = ymtProductsIWapper.selectAgentProductByProductId(ymtCatalogsI1.getsProductId());
                        Logger.verifyEquals(queryagentpricechainCall.getJsonObject().get("data").getAsJsonObject().get("currency").getAsString(),agentProductPo.getCurrency(),"验证currency");
                        if (x.getSellerId()==sellerId){
                            mch_relationWapper mchRelationWapper = new mch_relationWapper();
                            int agentType = mchRelationWapper.selectby(MapUtil.hashMap("mchId",agentUserId1)).get(0).getAgentType();
                            AgentPricePo agentPricePo = ymtProductsIWapper.selectAgentPriceByCatalogId(ymtCatalogsI1.getsCatalogId(),agentType).get(0);
                            Logger.verifyEquals(x.getFromParentPrice().doubleValue(),0.0,"验证fromParentPrice");
                            Logger.verifyEquals(x.getToChildPrice().setScale(1).doubleValue(),agentPricePo.getAgentPrice(),"验证toChildPrice");
                            YmtProductsI ymtProductsI = ymtProductsIWapper.selectProductByProductId(ymtCatalogsI1.getsProductId()).get(0);
                            Logger.verifyEquals(x.getTitle(),ymtProductsI.getsProduct(),"验证title");
                            Logger.verifyEquals(x.getPictureUrl(),ymtProductsI.getsPicUrl(),"验证pictureUrl");
                        }else{
                            mch_relationWapper mchRelationWapper = new mch_relationWapper();
                            int agentType = mchRelationWapper.selectby(MapUtil.hashMap("mchId",agentUserId1)).get(0).getAgentType();
                            AgentPricePo agentPricePo = ymtProductsIWapper.selectAgentPriceByCatalogId(ymtCatalogsI1.getsCatalogId(),agentType).get(0);
                            Logger.verifyEquals(x.getToChildPrice().doubleValue(),0.0,"验证toChildPrice");
                            YmtProductsI ymtProductsI = ymtProductsIWapper.selectProductByProductId(ymtCatalogsI.getsProductId()).get(0);
                            Logger.verifyEquals(x.getFromParentPrice().setScale(1).doubleValue(),agentPricePo.getAgentPrice(),"验证fromParentPrice");
                            Logger.verifyEquals(x.getTitle(),ymtProductsI.getsProduct(),"验证title");
                            Logger.verifyEquals(x.getPictureUrl(),ymtProductsI.getsPicUrl(),"验证pictureUrl");
                        }

                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                });
            });
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QueryAgentPriceChain_03() {
		Logger.start(true,"vip渠道->代理查询代理商品价格链，查询成功");
		try {
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,vipRootUserName,true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService.initImportAgentProduct(vipAgentUserId1,vipAgentUserName1,productId,vipRootUserId,true);

			String agentProductId = AddAgentProductCallService.ImportAgentProduct(importAgentProductBean);
			List<String> catalogIds = new ArrayList<>();
			ymtCatalogsIWapper.selectCatalogsByProductId(agentProductId).forEach(p->{
				catalogIds.add(p.getsCatalogId());
			});
			queryagentpricechainBean.setCatalogIds(catalogIds);
			queryagentpricechainCall.setData(queryagentpricechainBean);
			queryagentpricechainCall.callService();
			Logger.verifyEquals("200",queryagentpricechainCall.getString("code"),"验证规格");

            HashMap<String, List<CatalogLinkedMapDto>> result = queryagentpricechainCall.getResult();

            catalogIds.forEach(p->{
                result.get(p).forEach(x->{
                    try {
                        YmtCatalogsI ymtCatalogsI = ymtCatalogsIWapper.selectCatalogsByCatalogId(p);
                        YmtCatalogsI ymtCatalogsI1 = ymtCatalogsIWapper.selectCatalogsByCatalogId(ymtCatalogsI.getRootCatalogId());

                        AgentProductPo agentProductPo = ymtProductsIWapper.selectAgentProductByProductId(ymtCatalogsI1.getsProductId());
                        Logger.verifyEquals(queryagentpricechainCall.getJsonObject().get("data").getAsJsonObject().get("currency").getAsString(),agentProductPo.getCurrency(),"验证currency");

                        if (x.getSellerId()==vipRootUserId){
                            mch_relationWapper mchRelationWapper = new mch_relationWapper();
                            int agentType = mchRelationWapper.selectby(MapUtil.hashMap("mchId",vipAgentUserId1)).get(0).getAgentType();
                            AgentPricePo agentPricePo = ymtProductsIWapper.selectAgentPriceByCatalogId(ymtCatalogsI1.getsCatalogId(),agentType).get(0);
                            Logger.verifyEquals(x.getFromParentPrice().doubleValue(),0.0,"验证fromParentPrice");
                            Logger.verifyEquals(x.getToChildPrice().setScale(1).doubleValue(),agentPricePo.getAgentPrice(),"验证toChildPrice");
                            YmtProductsI ymtProductsI = ymtProductsIWapper.selectProductByProductId(ymtCatalogsI1.getsProductId()).get(0);
                            Logger.verifyEquals(x.getTitle(),ymtProductsI.getsProduct(),"验证title");
                            Logger.verifyEquals(x.getPictureUrl(),ymtProductsI.getsPicUrl(),"验证pictureUrl");
                        }else{
                            mch_relationWapper mchRelationWapper = new mch_relationWapper();
                            int agentType = mchRelationWapper.selectby(MapUtil.hashMap("mchId",vipAgentUserId1)).get(0).getAgentType();
                            AgentPricePo agentPricePo = ymtProductsIWapper.selectAgentPriceByCatalogId(ymtCatalogsI1.getsCatalogId(),agentType).get(0);
                            Logger.verifyEquals(x.getToChildPrice().doubleValue(),0.0,"验证toChildPrice");
                            YmtProductsI ymtProductsI = ymtProductsIWapper.selectProductByProductId(ymtCatalogsI.getsProductId()).get(0);
                            Logger.verifyEquals(x.getFromParentPrice().setScale(1).doubleValue(),agentPricePo.getAgentPrice(),"验证fromParentPrice");
                            Logger.verifyEquals(x.getTitle(),ymtProductsI.getsProduct(),"验证title");
                            Logger.verifyEquals(x.getPictureUrl(),ymtProductsI.getsPicUrl(),"验证pictureUrl");
                        }

                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                });
            });
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QueryAgentPriceChain_04() {
		Logger.start(true,"vip渠道->代理1->代理2，代理2查询商品价格链，查询成功");
		try {
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,vipRootUserName,true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);

			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService.initImportAgentProduct(vipAgentUserId1,vipAgentUserName1,productId,vipRootUserId,true);
			String agentProductId = AddAgentProductCallService.ImportAgentProduct(importAgentProductBean);

			ImportAgentProductBean importAgentProductBean1 = AddAgentProductCallService.initImportAgentProduct(vipAgentUserId2,vipAgentUserName2,agentProductId,vipAgentUserId1,false);
			String agentProductId1 = AddAgentProductCallService.ImportAgentProduct(importAgentProductBean1);

			List<String> catalogIds = new ArrayList<>();
			ymtCatalogsIWapper.selectCatalogsByProductId(agentProductId1).forEach(p->{
				catalogIds.add(p.getsCatalogId());
			});
			queryagentpricechainBean.setCatalogIds(catalogIds);
			queryagentpricechainCall.setData(queryagentpricechainBean);
			queryagentpricechainCall.callService();
			Logger.verifyEquals("200",queryagentpricechainCall.getString("code"),"验证规格");
            HashMap<String, List<CatalogLinkedMapDto>> result = queryagentpricechainCall.getResult();

            catalogIds.forEach(p->{
                result.get(p).forEach(x->{
                    try {
                        YmtCatalogsI ymtCatalogsI = ymtCatalogsIWapper.selectCatalogsByCatalogId(p);
                        YmtCatalogsI ymtCatalogsI1 = ymtCatalogsIWapper.selectCatalogsByCatalogId(ymtCatalogsI.getRootCatalogId());
                        YmtCatalogsI ymtCatalogsI2 = ymtCatalogsIWapper.selectCatalogsByCatalogId(ymtCatalogsI.getParentCatalogId());

                        AgentProductPo agentProductPo = ymtProductsIWapper.selectAgentProductByProductId(ymtCatalogsI1.getsProductId());
                        Logger.verifyEquals(queryagentpricechainCall.getJsonObject().get("data").getAsJsonObject().get("currency").getAsString(),agentProductPo.getCurrency(),"验证currency");

                        if (x.getSellerId()==vipRootUserId){
                            mch_relationWapper mchRelationWapper = new mch_relationWapper();
                            int agentType = mchRelationWapper.selectby(MapUtil.hashMap("mchId",vipAgentUserId1)).get(0).getAgentType();
                            AgentPricePo agentPricePo = ymtProductsIWapper.selectAgentPriceByCatalogId(ymtCatalogsI1.getsCatalogId(),agentType).get(0);
                            Logger.verifyEquals(x.getFromParentPrice().doubleValue(),0.0,"验证fromParentPrice");
                            Logger.verifyEquals(x.getToChildPrice().setScale(1).doubleValue(),agentPricePo.getAgentPrice(),"验证toChildPrice");
                            YmtProductsI ymtProductsI = ymtProductsIWapper.selectProductByProductId(ymtCatalogsI1.getsProductId()).get(0);
                            Logger.verifyEquals(x.getTitle(),ymtProductsI.getsProduct(),"验证title");
                            Logger.verifyEquals(x.getPictureUrl(),ymtProductsI.getsPicUrl(),"验证pictureUrl");
                        }else if (x.getSellerId()==vipAgentUserId1){
                            mch_relationWapper mchRelationWapper = new mch_relationWapper();
                            int agentType = mchRelationWapper.selectby(MapUtil.hashMap("mchId",vipAgentUserId1)).get(0).getAgentType();
                            AgentPricePo agentPricePo = ymtProductsIWapper.selectAgentPriceByCatalogId(ymtCatalogsI1.getsCatalogId(),agentType).get(0);

                            int agentType1 = mchRelationWapper.selectby(MapUtil.hashMap("mchId",vipAgentUserId2)).get(0).getAgentType();
                            AgentPricePo agentPricePo1 = ymtProductsIWapper.selectAgentPriceByCatalogId(ymtCatalogsI.getParentCatalogId(),agentType1).get(0);

                            Logger.verifyEquals(x.getToChildPrice().setScale(1).doubleValue(),agentPricePo1.getAgentPrice(),"验证toChildPrice");
                            Logger.verifyEquals(x.getFromParentPrice().setScale(1).doubleValue(),agentPricePo.getAgentPrice(),"验证fromParentPrice");
                            YmtProductsI ymtProductsI = ymtProductsIWapper.selectProductByProductId(ymtCatalogsI2.getsProductId()).get(0);
                            Logger.verifyEquals(x.getTitle(),ymtProductsI.getsProduct(),"验证title");
                            Logger.verifyEquals(x.getPictureUrl(),ymtProductsI.getsPicUrl(),"验证pictureUrl");
                        } else{
                            mch_relationWapper mchRelationWapper = new mch_relationWapper();
                            int agentType1 = mchRelationWapper.selectby(MapUtil.hashMap("mchId",vipAgentUserId2)).get(0).getAgentType();
                            AgentPricePo agentPricePo = ymtProductsIWapper.selectAgentPriceByCatalogId(ymtCatalogsI.getParentCatalogId(),agentType1).get(0);

                            Logger.verifyEquals(x.getToChildPrice().doubleValue(),0.0,"验证toChildPrice");
                            YmtProductsI ymtProductsI = ymtProductsIWapper.selectProductByProductId(ymtCatalogsI.getsProductId()).get(0);
                            Logger.verifyEquals(x.getFromParentPrice().setScale(1).doubleValue(),agentPricePo.getAgentPrice(),"验证fromParentPrice");
                            Logger.verifyEquals(x.getTitle(),ymtProductsI.getsProduct(),"验证title");
                            Logger.verifyEquals(x.getPictureUrl(),ymtProductsI.getsPicUrl(),"验证pictureUrl");
                        }

                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                });
            });
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QueryAgentPriceChain_05() {
		Logger.start(true,"vip渠道->代理1->代理2,查询代理1代理商品价格链，查询成功");
		try {
            AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,vipRootUserName,true);
            String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);

            ImportAgentProductBean importAgentProductBean = AddAgentProductCallService.initImportAgentProduct(vipAgentUserId1,vipAgentUserName1,productId,vipRootUserId,true);
            String agentProductId = AddAgentProductCallService.ImportAgentProduct(importAgentProductBean);

            ImportAgentProductBean importAgentProductBean1 = AddAgentProductCallService.initImportAgentProduct(vipAgentUserId2,vipAgentUserName2,agentProductId,vipAgentUserId1,false);
            String agentProductId1 = AddAgentProductCallService.ImportAgentProduct(importAgentProductBean1);

			List<String> catalogIds = new ArrayList<>();
			ymtCatalogsIWapper.selectCatalogsByProductId(agentProductId).forEach(p->{
				catalogIds.add(p.getsCatalogId());
			});
			queryagentpricechainBean.setCatalogIds(catalogIds);
			queryagentpricechainCall.setData(queryagentpricechainBean);
			queryagentpricechainCall.callService();
            Logger.verifyEquals("200",queryagentpricechainCall.getString("code"),"验证规格");

            HashMap<String, List<CatalogLinkedMapDto>> result = queryagentpricechainCall.getResult();

            catalogIds.forEach(p->{
                result.get(p).forEach(x->{
                    try {
                        YmtCatalogsI ymtCatalogsI = ymtCatalogsIWapper.selectCatalogsByCatalogId(p);
                        YmtCatalogsI ymtCatalogsI1 = ymtCatalogsIWapper.selectCatalogsByCatalogId(ymtCatalogsI.getRootCatalogId());

                        AgentProductPo agentProductPo = ymtProductsIWapper.selectAgentProductByProductId(ymtCatalogsI1.getsProductId());
                        Logger.verifyEquals(queryagentpricechainCall.getJsonObject().get("data").getAsJsonObject().get("currency").getAsString(),agentProductPo.getCurrency(),"验证currency");

                        if (x.getSellerId()==vipRootUserId){
                            mch_relationWapper mchRelationWapper = new mch_relationWapper();
                            int agentType = mchRelationWapper.selectby(MapUtil.hashMap("mchId",vipAgentUserId1)).get(0).getAgentType();
                            AgentPricePo agentPricePo = ymtProductsIWapper.selectAgentPriceByCatalogId(ymtCatalogsI1.getsCatalogId(),agentType).get(0);
                            Logger.verifyEquals(x.getFromParentPrice().doubleValue(),0.0,"验证fromParentPrice");
                            Logger.verifyEquals(x.getToChildPrice().setScale(1).doubleValue(),agentPricePo.getAgentPrice(),"验证toChildPrice");
                            YmtProductsI ymtProductsI = ymtProductsIWapper.selectProductByProductId(ymtCatalogsI1.getsProductId()).get(0);
                            Logger.verifyEquals(x.getTitle(),ymtProductsI.getsProduct(),"验证title");
                            Logger.verifyEquals(x.getPictureUrl(),ymtProductsI.getsPicUrl(),"验证pictureUrl");
                        }else{
                            mch_relationWapper mchRelationWapper = new mch_relationWapper();
                            int agentType = mchRelationWapper.selectby(MapUtil.hashMap("mchId",vipAgentUserId1)).get(0).getAgentType();
                            AgentPricePo agentPricePo = ymtProductsIWapper.selectAgentPriceByCatalogId(ymtCatalogsI1.getsCatalogId(),agentType).get(0);
                            Logger.verifyEquals(x.getToChildPrice().doubleValue(),0.0,"验证toChildPrice");
                            YmtProductsI ymtProductsI = ymtProductsIWapper.selectProductByProductId(ymtCatalogsI.getsProductId()).get(0);
                            Logger.verifyEquals(x.getFromParentPrice().setScale(1).doubleValue(),agentPricePo.getAgentPrice(),"验证fromParentPrice");
                            Logger.verifyEquals(x.getTitle(),ymtProductsI.getsProduct(),"验证title");
                            Logger.verifyEquals(x.getPictureUrl(),ymtProductsI.getsPicUrl(),"验证pictureUrl");
                        }

                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                });
            });
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QueryAgentPriceChain_06() {
		Logger.start(true,"规格列表为空，查询失败");
		try {
			List<String> catalogIds = new ArrayList<>();
			queryagentpricechainBean.setCatalogIds(catalogIds);
			queryagentpricechainCall.setData(queryagentpricechainBean);
			queryagentpricechainCall.callService();
			Logger.verifyEquals("500",queryagentpricechainCall.getString("code"),"验证规格");
		} catch (Exception e) {
			
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QueryAgentPriceChain_07() {
		Logger.start(true,"vip渠道->代理1->代理2，vip渠道未设置代理价，查看vip1的商品价格链");
		try {
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,vipRootUserName,false);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);

			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService.initImportAgentProduct(vipAgentUserId1,vipAgentUserName1,productId,vipRootUserId,false);
			String agentProductId = AddAgentProductCallService.ImportAgentProduct(importAgentProductBean);

			ImportAgentProductBean importAgentProductBean1 = AddAgentProductCallService.initImportAgentProduct(vipAgentUserId2,vipAgentUserName2,agentProductId,vipAgentUserId1,false);
			String agentProductId1 = AddAgentProductCallService.ImportAgentProduct(importAgentProductBean1);

		
			
			List<String> catalogIds = new ArrayList<>();
			ymtCatalogsIWapper.selectCatalogsByProductId(agentProductId).forEach(p->{
				catalogIds.add(p.getsCatalogId());
			});
			queryagentpricechainBean.setCatalogIds(catalogIds);
			queryagentpricechainCall.setData(queryagentpricechainBean);
			queryagentpricechainCall.callService();
			Logger.verifyEquals("200",queryagentpricechainCall.getString("code"),"验证规格");

			HashMap<String, List<CatalogLinkedMapDto>> result = queryagentpricechainCall.getResult();
			
			catalogIds.forEach(p->{
				result.get(p).forEach(x->{
					try {
						YmtCatalogsI ymtCatalogsI = ymtCatalogsIWapper.selectCatalogsByCatalogId(p);
						YmtCatalogsI ymtCatalogsI1 = ymtCatalogsIWapper.selectCatalogsByCatalogId(ymtCatalogsI.getRootCatalogId());
                        AgentProductPo agentProductPo = ymtProductsIWapper.selectAgentProductByProductId(ymtCatalogsI1.getsProductId());
                        Logger.verifyEquals(queryagentpricechainCall.getJsonObject().get("data").getAsJsonObject().get("currency").getAsString(),agentProductPo.getCurrency(),"验证currency");
                        if (x.getSellerId()==vipRootUserId){
                        	Logger.verifyEquals(x.getFromParentPrice().doubleValue(),0.0,"验证fromParentPrice");
							Logger.verifyEquals(x.getToChildPrice(),ymtCatalogsI1.getfQuotePrice(),"验证toChildPrice");
							YmtProductsI ymtProductsI = ymtProductsIWapper.selectProductByProductId(ymtCatalogsI1.getsProductId()).get(0);
							Logger.verifyEquals(x.getTitle(),ymtProductsI.getsProduct(),"验证title");
							Logger.verifyEquals(x.getPictureUrl(),ymtProductsI.getsPicUrl(),"验证pictureUrl");
						}else{
							Logger.verifyEquals(x.getToChildPrice().doubleValue(),0.0,"验证toChildPrice");
							YmtProductsI ymtProductsI = ymtProductsIWapper.selectProductByProductId(ymtCatalogsI.getsProductId()).get(0);
							Logger.verifyEquals(x.getFromParentPrice(),ymtCatalogsI1.getfQuotePrice(),"验证fromParentPrice");
							Logger.verifyEquals(x.getTitle(),ymtProductsI.getsProduct(),"验证title");
							Logger.verifyEquals(x.getPictureUrl(),ymtProductsI.getsPicUrl(),"验证pictureUrl");
						}

					} catch (InterruptedException e) {
						e.printStackTrace();
					}
				});
			});
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QueryAgentPriceChain_08() {
		Logger.start(true, "渠道商发布商品，不自动继承的代理,判断进货价是否正确..两个都可以查出来");
		try {
			// 创建两个用户
			UserCreateBean usercreateBean1 = DGUserCallService.initUsercreateBean();
			int userId_channl = DGUserCallService.UserCreateCall(usercreateBean1);
			usercreateBean1 = DGUserCallService.initUsercreateBean();
			int userId_agent = DGUserCallService.UserCreateCall(usercreateBean1);
			// 设置渠道商
			createmchBean createmchbean = GodmchManageCallService.InitcreatemchBeanForChannel(userId_channl);
			GodmchManageCallService.createmchCallForChannel(createmchbean);
			// 渠道商创建一个邀请码，出来一个自动继承的代理商、自动继承渠道商刚才的商品
			CreateCodeBean createbean = GodmchManageCallService.InitcreateCodeBeanForAgent(userId_channl);
			createbean.setAgentModel(1);
			CreateCodeCall CreateCodeCall = GodmchManageCallService.createCodeCall(createbean);
			List<createmchBean> createmchList = GodmchManageCallService.InitcreatemchBeanForAgent(userId_channl,
					userId_agent); //
			createmchList.get(0).setCode(CreateCodeCall.getCode());
			GodmchManageCallService
					.createmchCallForAgent(createmchList.toArray(new createmchBean[createmchList.size()]));

			// 给渠道商创建一个商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(userId_channl,
					usercreateBean1.getNickname(), true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			//代理商导入
			ImportAgentProductBean initImportAgentProduct = AddAgentProductCallService.initImportAgentProduct(
					userId_agent, usercreateBean1.getNickname(), productId, userId_channl, false);
			String productId1 = AddAgentProductCallService.ImportAgentProduct(initImportAgentProduct);
			
			ProductDetailsDto selectProductDetails = AddAgentProductCallService.selectProductDetails(userId_agent,
					productId1);
			List<String> catalogs=new ArrayList<>();
			selectProductDetails.getCatalogList().forEach(c->{
				catalogs.add(c.getCatalogId());
			});
			
			
			Thread.sleep(5000);
			//渠道商查询
			queryagentpricechainBean.setCatalogIds(catalogs);
			queryagentpricechainBean.setUserId(userId_channl);
			queryagentpricechainCall.setData(queryagentpricechainBean);
			queryagentpricechainCall.callService();
			Logger.verifyEquals("200", queryagentpricechainCall.getString("code"), "验证code");
			

			//代理商查询
			queryagentpricechainBean.setCatalogIds(catalogs);
			queryagentpricechainBean.setUserId(userId_agent);
			queryagentpricechainCall.setData(queryagentpricechainBean);
			queryagentpricechainCall.callService();
			Logger.verifyEquals("200", queryagentpricechainCall.getString("code"), "验证code");
			

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	@Ignore  //普通商户  没有自动继承模式了，只有独立商户可以
	public void Tc_QueryAgentPriceChain_09() {
		Logger.start(true, "渠道商发布商品，下面自动继承的代理自动继承,判断进货价是否正确..只有代理可以查到");
		try {
			// 创建两个用户
			UserCreateBean usercreateBean1 = DGUserCallService.initUsercreateBean();
			int userId_channl = DGUserCallService.UserCreateCall(usercreateBean1);
			usercreateBean1 = DGUserCallService.initUsercreateBean();
			int userId_agent = DGUserCallService.UserCreateCall(usercreateBean1);
			// 设置渠道商
			createmchBean createmchbean = GodmchManageCallService.InitcreatemchBeanForChannel(userId_channl);
			GodmchManageCallService.createmchCallForChannel(createmchbean);
			// 渠道商创建一个邀请码，出来一个自动继承的代理商、自动继承渠道商刚才的商品
			CreateCodeBean createbean = GodmchManageCallService.InitcreateCodeBeanForAgent(userId_channl);
			createbean.setAgentModel(2);// 自动继承
			CreateCodeCall CreateCodeCall = GodmchManageCallService.createCodeCall(createbean);
			List<createmchBean> createmchList = GodmchManageCallService.InitcreatemchBeanForAgent(userId_channl,
					userId_agent); //
			createmchList.get(0).setCode(CreateCodeCall.getCode());
			GodmchManageCallService
					.createmchCallForAgent(createmchList.toArray(new createmchBean[createmchList.size()]));

			
			// 给渠道商创建一个商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(userId_channl,
					usercreateBean1.getNickname(), true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			Thread.sleep(5000);
//			//代理商导入
//			ImportAgentProductBean initImportAgentProduct = AddAgentProductCallService.initImportAgentProduct(
//					userId_agent, usercreateBean1.getNickname(), productId, userId_channl, false);
//			String productId1 = AddAgentProductCallService.ImportAgentProduct(initImportAgentProduct);
			
			List<ProductListDto> getProductLists = AddAgentProductCallService.GetProductLists(userId_agent);
			System.out.println(getProductLists);
			
			ProductDetailsBean initGetProductDetails = AddAgentProductCallService.initGetProductDetails(userId_channl, userId_channl, productId, true);
			ProductDetailsDto selectProductDetails = AddAgentProductCallService.GetProductDetailsCall(initGetProductDetails);
			
			List<String> catalogs=new ArrayList<>();
			selectProductDetails.getCatalogList().forEach(c->{
				catalogs.add(c.getCatalogId());
			});
			
			ProductDetailsBean initGetProductDetails1 = AddAgentProductCallService.initGetProductDetails(userId_channl, userId_agent, productId, true);
			ProductDetailsDto selectProductDetails1 = AddAgentProductCallService.GetProductDetailsCall(initGetProductDetails1);
			
			List<String> catalogs1=new ArrayList<>();
			selectProductDetails1.getCatalogList().forEach(c->{
				catalogs1.add(c.getCatalogId());
			});
			
			Thread.sleep(5000);

			//代理商查询
			queryagentpricechainBean.setCatalogIds(catalogs1);
			queryagentpricechainBean.setUserId(userId_agent);
			queryagentpricechainCall.setData(queryagentpricechainBean);
			queryagentpricechainCall.callService();
			Logger.verifyEquals("200", queryagentpricechainCall.getString("code"), "验证code");
			

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QueryAgentPriceChain_10() {
		Logger.start(true,"vip渠道->代理1->代理2，代理2查询商品价格链，判断各级规格id查询");
		try {
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(vipRootUserId,vipRootUserName,true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);

			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService.initImportAgentProduct(vipAgentUserId1,vipAgentUserName1,productId,vipRootUserId,true);
			String agentProductId = AddAgentProductCallService.ImportAgentProduct(importAgentProductBean);

			ImportAgentProductBean importAgentProductBean1 = AddAgentProductCallService.initImportAgentProduct(vipAgentUserId2,vipAgentUserName2,agentProductId,vipAgentUserId1,false);
			String agentProductId1 = AddAgentProductCallService.ImportAgentProduct(importAgentProductBean1);

			List<String> catalogIds = new ArrayList<>();
			ymtCatalogsIWapper.selectCatalogsByProductId(agentProductId1).forEach(p->{
				catalogIds.add(p.getsCatalogId());
			});
			queryagentpricechainBean.setCatalogIds(catalogIds);
			queryagentpricechainCall.setData(queryagentpricechainBean);
			queryagentpricechainCall.callService();
			Logger.verifyEquals("200",queryagentpricechainCall.getString("code"),"验证规格");
            HashMap<String, List<CatalogLinkedMapDto>> result = queryagentpricechainCall.getResult();

            catalogIds.forEach(p->{
                result.get(p).forEach(x->{
                    try {
                        YmtCatalogsI ymtCatalogsI = ymtCatalogsIWapper.selectCatalogsByCatalogId(p);
                        YmtCatalogsI ymtCatalogsI1 = ymtCatalogsIWapper.selectCatalogsByCatalogId(ymtCatalogsI.getRootCatalogId());
                        YmtCatalogsI ymtCatalogsI2 = ymtCatalogsIWapper.selectCatalogsByCatalogId(ymtCatalogsI.getParentCatalogId());

                        AgentProductPo agentProductPo = ymtProductsIWapper.selectAgentProductByProductId(ymtCatalogsI1.getsProductId());
                        Logger.verifyEquals(queryagentpricechainCall.getJsonObject().get("data").getAsJsonObject().get("currency").getAsString(),agentProductPo.getCurrency(),"验证currency");

                        if (x.getSellerId()==vipRootUserId){
                            mch_relationWapper mchRelationWapper = new mch_relationWapper();
                            int agentType = mchRelationWapper.selectby(MapUtil.hashMap("mchId",vipAgentUserId1)).get(0).getAgentType();
                            AgentPricePo agentPricePo = ymtProductsIWapper.selectAgentPriceByCatalogId(ymtCatalogsI1.getsCatalogId(),agentType).get(0);
                            Logger.verifyEquals(x.getFromParentPrice().doubleValue(),0.0,"验证fromParentPrice");
                            Logger.verifyEquals(x.getToChildPrice().setScale(1).doubleValue(),agentPricePo.getAgentPrice(),"验证toChildPrice");
                            YmtProductsI ymtProductsI = ymtProductsIWapper.selectProductByProductId(ymtCatalogsI1.getsProductId()).get(0);
                            Logger.verifyEquals(x.getTitle(),ymtProductsI.getsProduct(),"验证title");
                            Logger.verifyEquals(x.getPictureUrl(),ymtProductsI.getsPicUrl(),"验证pictureUrl");
                            Logger.verifyEquals(x.getCatalogId(),ymtCatalogsI1.getsCatalogId(),"验证Root级别cataLogId");
                        }else if (x.getSellerId()==vipAgentUserId1){
                            mch_relationWapper mchRelationWapper = new mch_relationWapper();
                            int agentType = mchRelationWapper.selectby(MapUtil.hashMap("mchId",vipAgentUserId1)).get(0).getAgentType();
                            AgentPricePo agentPricePo = ymtProductsIWapper.selectAgentPriceByCatalogId(ymtCatalogsI1.getsCatalogId(),agentType).get(0);

                            int agentType1 = mchRelationWapper.selectby(MapUtil.hashMap("mchId",vipAgentUserId2)).get(0).getAgentType();
                            AgentPricePo agentPricePo1 = ymtProductsIWapper.selectAgentPriceByCatalogId(ymtCatalogsI.getParentCatalogId(),agentType1).get(0);

                            Logger.verifyEquals(x.getToChildPrice().setScale(1).doubleValue(),agentPricePo1.getAgentPrice(),"验证toChildPrice");
                            Logger.verifyEquals(x.getFromParentPrice().setScale(1).doubleValue(),agentPricePo.getAgentPrice(),"验证fromParentPrice");
                            YmtProductsI ymtProductsI = ymtProductsIWapper.selectProductByProductId(ymtCatalogsI2.getsProductId()).get(0);
                            Logger.verifyEquals(x.getTitle(),ymtProductsI.getsProduct(),"验证title");
                            Logger.verifyEquals(x.getPictureUrl(),ymtProductsI.getsPicUrl(),"验证pictureUrl");
                            Logger.verifyEquals(x.getCatalogId(),ymtCatalogsI.getParentCatalogId(),"验证代理1cataLogID");
                        } else{
                            mch_relationWapper mchRelationWapper = new mch_relationWapper();
                            int agentType1 = mchRelationWapper.selectby(MapUtil.hashMap("mchId",vipAgentUserId2)).get(0).getAgentType();
                            AgentPricePo agentPricePo = ymtProductsIWapper.selectAgentPriceByCatalogId(ymtCatalogsI.getParentCatalogId(),agentType1).get(0);
                            Logger.verifyEquals(x.getToChildPrice().doubleValue(),0.0,"验证toChildPrice");
                            YmtProductsI ymtProductsI = ymtProductsIWapper.selectProductByProductId(ymtCatalogsI.getsProductId()).get(0);
                            Logger.verifyEquals(x.getFromParentPrice().setScale(1).doubleValue(),agentPricePo.getAgentPrice(),"验证fromParentPrice");
                            Logger.verifyEquals(x.getTitle(),ymtProductsI.getsProduct(),"验证title");
                            Logger.verifyEquals(x.getPictureUrl(),ymtProductsI.getsPicUrl(),"验证pictureUrl");
                            Logger.verifyEquals(x.getCatalogId(),p,"验证代理2cataLogId");
                        }

                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                });
            });
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QueryAgentPriceChain_11() {
		Logger.start(true,"商户下分销小店，代理查询商品价格链，判断各级规格分佣");
		try {
			
//			GodmchManageCallService.CreateDistributor(mchId)
			
			int userId = 500945639;
			int AgentUserId = 500945640;
			// 给渠道商创建一个商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(userId, "", false);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			Thread.sleep(5000);

			ProductDetailsBean initGetProductDetails1 = AddAgentProductCallService.initGetProductDetails(userId,
					AgentUserId, productId, true);
			ProductDetailsDto selectProductDetails1 = AddAgentProductCallService
					.GetProductDetailsCall(initGetProductDetails1);

			List<String> catalogs1 = new ArrayList<>();
			selectProductDetails1.getCatalogList().forEach(c -> {
				catalogs1.add(c.getCatalogId());
			});

			Thread.sleep(5000);

			// 代理商查询
			queryagentpricechainBean.setCatalogIds(catalogs1);
			queryagentpricechainBean.setUserId(AgentUserId);
			queryagentpricechainCall.setData(queryagentpricechainBean);
			queryagentpricechainCall.callService();
			Logger.verifyEquals("200", queryagentpricechainCall.getString("code"), "验证code");

			HashMap<String, List<CatalogLinkedMapDto>> result = queryagentpricechainCall.getResult();
			catalogs1.forEach(p -> {
				result.get(p).forEach(x -> {
					if (x.getSellerId() == userId) {
						Logger.verifyEquals(x.getFromParentPrice().doubleValue(),0.0,"验证fromParentPrice");
						Logger.verifyEquals(x.getFromParentPriceType(),0,"验证FromParentPriceType");
					} else if (x.getSellerId() == AgentUserId) {
						Logger.verifyEquals(x.getFromParentPrice().doubleValue(),2.0,"验证fromParentPrice");
						Logger.verifyEquals(x.getFromParentPriceType(),1,"验证FromParentPriceType");
						Logger.verifyEquals(x.getToChildPrice().setScale(1).doubleValue(),0.0,"验证toChildPrice");
					}
				});
			});

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QueryAgentPriceChain_12() {
		Logger.start(true,"渠道->代理->分销小店，分销小店查询商品价格链，判断各级规格分佣");
		try {
			int userId = 500949763;
			int AgentUserId = 500949764;
			int AgentUserId1 = 500949765;
			// 给渠道商创建一个商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(userId, "", false);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService.initImportAgentProduct(AgentUserId,"",productId,userId,false);
			String agentProductId = AddAgentProductCallService.ImportAgentProduct(importAgentProductBean);
			Thread.sleep(5000);
			ProductDetailsBean initGetProductDetails1 = AddAgentProductCallService.initGetProductDetails(userId,
					AgentUserId1, agentProductId, true);
			ProductDetailsDto selectProductDetails1 = AddAgentProductCallService
					.GetProductDetailsCall(initGetProductDetails1);
			List<String> catalogs1 = new ArrayList<>();
			selectProductDetails1.getCatalogList().forEach(c -> {
				catalogs1.add(c.getCatalogId());
			});
			Thread.sleep(5000);
			// 代理商查询
			queryagentpricechainBean.setCatalogIds(catalogs1);
			queryagentpricechainBean.setUserId(AgentUserId1);
			queryagentpricechainCall.setData(queryagentpricechainBean);
			queryagentpricechainCall.callService();
			Logger.verifyEquals("200", queryagentpricechainCall.getString("code"), "验证code");
			
			HashMap<String, List<CatalogLinkedMapDto>> result = queryagentpricechainCall.getResult();
			catalogs1.forEach(p -> {
				result.get(p).forEach(x -> {
					if (x.getSellerId() == userId) {
						Logger.verifyEquals(x.getFromParentPrice().doubleValue(),0.0,"验证fromParentPrice");
						Logger.verifyEquals(x.getToChildPrice().doubleValue(),900.0,"验证toChildPrice");
						Logger.verifyEquals(x.getFromParentPriceType(),0,"验证FromParentPriceType");
					} else if (x.getSellerId() == AgentUserId) {
						Logger.verifyEquals(x.getFromParentPrice().doubleValue(),900.0,"验证fromParentPrice");
						Logger.verifyEquals(x.getToChildPrice().doubleValue(),1000.0,"验证toChildPrice");
						Logger.verifyEquals(x.getFromParentPriceType(),0,"验证FromParentPriceType");
					}else if (x.getSellerId() == AgentUserId1) {
						Logger.verifyEquals(x.getFromParentPrice().doubleValue(),30.0,"验证fromParentPrice");
						Logger.verifyEquals(x.getToChildPrice().setScale(1).doubleValue(),0.0,"验证toChildPrice");
						Logger.verifyEquals(x.getFromParentPriceType(),1,"验证FromParentPriceType");
					}
				});
			});
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QueryAgentPriceChain_13() {
		Logger.start(true,"商户下分销小店，代理查询商品价格链，判断各级规格分佣");
		try {
			//创建一个商户和分销小店
			Integer MchId = GodmchManageCallService.CreateGodMch();
			Integer StoreId = GodmchManageCallService.CreateStores(MchId, 20);
			//创建商品，小店会继承
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(MchId, "", true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			//创建一个权重5的分佣条件
			int RebateId = AddAgentProductCallService.AddCondictionRebate(addAgentProductBean,5,20);
			
			ProductDetailsBean initGetProductDetails = AddAgentProductCallService.initGetProductDetails(MchId,
					StoreId, productId, true);
			ProductDetailsDto selectProductDetails = AddAgentProductCallService
					.GetProductDetailsCall(initGetProductDetails);
			List<String> catalogs = new ArrayList<>();
			selectProductDetails.getCatalogList().forEach(c -> {
				catalogs.add(c.getCatalogId());
			});

			Thread.sleep(5000);
			// 小店查询代理链
			queryagentpricechainBean.setCatalogIds(catalogs);
			queryagentpricechainBean.setUserId(StoreId);
			queryagentpricechainCall.setData(queryagentpricechainBean);
			queryagentpricechainCall.callService();
			Logger.verifyEquals("200", queryagentpricechainCall.getString("code"), "验证code");
			HashMap<String, List<CatalogLinkedMapDto>> result = queryagentpricechainCall.getResult();
			catalogs.forEach(p -> {
				result.get(p).forEach(x -> {
					if (x.getSellerId() == MchId) {
						Logger.verifyEquals(x.getFromParentPrice().doubleValue(),0.0,"验证fromParentPrice");
						Logger.verifyEquals(x.getFromParentPriceType(),0,"验证FromParentPriceType");
					} else if (x.getSellerId() == StoreId) {
						Logger.verifyEquals(x.getFromParentPrice().doubleValue(),20.0,"验证fromParentPrice");
						Logger.verifyEquals(x.getFromParentPriceType(),1,"验证FromParentPriceType");
						Logger.verifyEquals(x.getToChildPrice().setScale(1).doubleValue(),0.0,"验证toChildPrice");
					}
				});
			});
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QueryAgentPriceChain_14() {
		Logger.start(true,"商户->代理->分销小店，小店10分佣，条件20分佣，查询为20分佣");
		try {
			
			//创建一个商户和分销小店
			Integer MchId = GodmchManageCallService.CreateGodMch();
			GodmchManageCallService.SetVip(MchId);
			Integer AgentId = GodmchManageCallService.CreateAgent(MchId);
			Integer StoreId = GodmchManageCallService.CreateStoresByAgent(MchId,AgentId, 10);
			//创建商品，小店会继承
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(MchId, "", true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService.initImportAgentProduct(AgentId,"",productId,MchId,true);
			String agentProductId = AddAgentProductCallService.ImportAgentProduct(importAgentProductBean);
			Thread.sleep(5000);
			//创建一个权重5的分佣条件
			int RebateId = AddAgentProductCallService.AddCondictionRebate(addAgentProductBean,5,30);
			AddConditionRebateBean initAddCondictionRebate = AddAgentProductCallService.InitAddCondictionRebate(addAgentProductBean,importAgentProductBean, 5,20);
			int RebateId1 = AddAgentProductCallService.AddCondictionRebate(initAddCondictionRebate);
			//小店查询到商品规格
			
			
			ProductDetailsBean initGetProductDetails = AddAgentProductCallService.initGetProductDetails(MchId,
					StoreId, productId, true);
			ProductDetailsDto selectProductDetails = AddAgentProductCallService
					.GetProductDetailsCall(initGetProductDetails);
			List<String> catalogs = new ArrayList<>();
			selectProductDetails.getCatalogList().forEach(c -> {
				catalogs.add(c.getCatalogId());
			});

			Thread.sleep(5000);
			// 小店查询代理链
			queryagentpricechainBean.setCatalogIds(catalogs);
			queryagentpricechainBean.setUserId(StoreId);
			queryagentpricechainCall.setData(queryagentpricechainBean);
			queryagentpricechainCall.callService();
			Logger.verifyEquals("200", queryagentpricechainCall.getString("code"), "验证code");
			HashMap<String, List<CatalogLinkedMapDto>> result = queryagentpricechainCall.getResult();
			catalogs.forEach(p -> {
				result.get(p).forEach(x -> {
					if (x.getSellerId() == MchId) {
						Logger.verifyEquals(x.getFromParentPrice().doubleValue(),0.0,"验证fromParentPrice");
						Logger.verifyEquals(x.getFromParentPriceType(),0,"验证FromParentPriceType");
					} else if (x.getSellerId() == StoreId) {
						Logger.verifyEquals(x.getFromParentPrice().doubleValue(),20.0,"验证fromParentPrice");
						Logger.verifyEquals(x.getFromParentPriceType(),1,"验证FromParentPriceType");
						Logger.verifyEquals(x.getToChildPrice().setScale(1).doubleValue(),0.0,"验证toChildPrice");
					}
				});
			});
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QueryAgentPriceChain_15() {
		Logger.start(true,"商户->代理->分销小店，小店10分佣，指定20分佣");
		try {
			//创建一个商户和分销小店
			Integer MchId = GodmchManageCallService.CreateGodMch();
			GodmchManageCallService.SetVip(MchId);
			Integer AgentId = GodmchManageCallService.CreateAgent(MchId);
			Integer StoreId = GodmchManageCallService.CreateStoresByAgent(MchId,AgentId, 10);
			//创建商品，小店会继承
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(MchId, "", true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService.initImportAgentProduct(AgentId,"",productId,MchId,false);
			String agentProductId = AddAgentProductCallService.ImportAgentProduct(importAgentProductBean);
			Thread.sleep(5000);
			EditProductRebateBean initEditProductRebateBean = AddAgentProductCallService.initEditProductRebateBean(agentProductId,StoreId, AgentId, 20);
			AddAgentProductCallService.EditProductRebateBean(initEditProductRebateBean);
			
			//小店查询到商品规格
			
			ProductDetailsBean initGetProductDetails = AddAgentProductCallService.initGetProductDetails(AgentId,
					StoreId, agentProductId, true);
			ProductDetailsDto selectProductDetails = AddAgentProductCallService
					.GetProductDetailsCall(initGetProductDetails);
			List<String> catalogs = new ArrayList<>();
			selectProductDetails.getCatalogList().forEach(c -> {
				catalogs.add(c.getCatalogId());
			});

			Thread.sleep(5000);
			// 小店查询代理链
			queryagentpricechainBean.setCatalogIds(catalogs);
			queryagentpricechainBean.setUserId(StoreId);
			queryagentpricechainCall.setData(queryagentpricechainBean);
			queryagentpricechainCall.callService();
			Logger.verifyEquals("200", queryagentpricechainCall.getString("code"), "验证code");
			HashMap<String, List<CatalogLinkedMapDto>> result = queryagentpricechainCall.getResult();
			catalogs.forEach(p -> {
				result.get(p).forEach(x -> {
					if (x.getSellerId() == MchId) {
						Logger.verifyEquals(x.getFromParentPrice().doubleValue(),0.0,"验证fromParentPrice");
						Logger.verifyEquals(x.getFromParentPriceType(),0,"验证FromParentPriceType");
					} else if (x.getSellerId() == StoreId) {
						Logger.verifyEquals(x.getFromParentPrice().doubleValue(),20.0,"验证fromParentPrice");
						Logger.verifyEquals(x.getFromParentPriceType(),1,"验证FromParentPriceType");
						Logger.verifyEquals(x.getToChildPrice().setScale(1).doubleValue(),0.0,"验证toChildPrice");
					}
				});
			});
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QueryAgentPriceChain_16() {
		Logger.start(true,"商户->分销小店，小店10分佣，指定商品20分佣   查询为20分佣");
		try {
			//创建一个商户和分销小店
			Integer MchId = GodmchManageCallService.CreateGodMch();
			Integer StoreId = GodmchManageCallService.CreateStores(MchId, 10);
			//创建商品，小店会继承
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(MchId, "", true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			Thread.sleep(5000);
			
			EditProductRebateBean initEditProductRebateBean = AddAgentProductCallService.initEditProductRebateBean(productId, StoreId, MchId, 20);
			AddAgentProductCallService.EditProductRebateBean(initEditProductRebateBean);
			//小店查询到商品规格
			
			ProductDetailsBean initGetProductDetails = AddAgentProductCallService.initGetProductDetails(MchId,
					StoreId, productId, true);
			ProductDetailsDto selectProductDetails = AddAgentProductCallService
					.GetProductDetailsCall(initGetProductDetails);
			List<String> catalogs = new ArrayList<>();
			selectProductDetails.getCatalogList().forEach(c -> {
				catalogs.add(c.getCatalogId());
			});
			Thread.sleep(5000);
			// 小店查询代理链
			queryagentpricechainBean.setCatalogIds(catalogs);
			queryagentpricechainBean.setUserId(StoreId);
			queryagentpricechainCall.setData(queryagentpricechainBean);
			queryagentpricechainCall.callService();
			Logger.verifyEquals("200", queryagentpricechainCall.getString("code"), "验证code");
			HashMap<String, List<CatalogLinkedMapDto>> result = queryagentpricechainCall.getResult();
			catalogs.forEach(p -> {
				result.get(p).forEach(x -> {
					if (x.getSellerId() == MchId) {
						Logger.verifyEquals(x.getFromParentPrice().doubleValue(),0.0,"验证fromParentPrice");
						Logger.verifyEquals(x.getFromParentPriceType(),0,"验证FromParentPriceType");
					} else if (x.getSellerId() == StoreId) {
						Logger.verifyEquals(x.getFromParentPrice().doubleValue(),20.0,"验证fromParentPrice");
						Logger.verifyEquals(x.getFromParentPriceType(),1,"验证FromParentPriceType");
						Logger.verifyEquals(x.getToChildPrice().setScale(1).doubleValue(),0.0,"验证toChildPrice");
					}
					
				});
			});
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QueryAgentPriceChain_17() {
		Logger.start(true,"商户->代理->代理->分销小店，小店10分佣，指定商品20分佣，条件30、查出来是20分佣");
		try {
			//创建一个商户和分销小店
			Integer MchId = GodmchManageCallService.CreateGodMch();
			GodmchManageCallService.SetVip(MchId);
			Integer AgentId = GodmchManageCallService.CreateAgent(MchId);
			Integer AgentId1 = GodmchManageCallService.CreateAgent(AgentId,MchId);
			System.out.println("创建分销小店");
			Integer StoreId = GodmchManageCallService.CreateStoresByAgent(MchId,AgentId1, 10);
			//创建商品，小店会继承
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(MchId, "", true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			ImportAgentProductBean importAgentProductBean = AddAgentProductCallService.initImportAgentProduct(AgentId,"",productId,MchId,true);
			String agentProductId = AddAgentProductCallService.ImportAgentProduct(importAgentProductBean);
			ImportAgentProductBean importAgentProductBean1 = AddAgentProductCallService.initImportAgentProduct(AgentId1,"",agentProductId,AgentId,true);
			String agentProductId1 = AddAgentProductCallService.ImportAgentProduct(importAgentProductBean1);
			Thread.sleep(5000);
			//创建一个权重5的分佣条件
			
			EditProductRebateBean initEditProductRebateBean = AddAgentProductCallService.initEditProductRebateBean(agentProductId1,StoreId, AgentId1, 20);
			AddAgentProductCallService.EditProductRebateBean(initEditProductRebateBean);
			
			AddConditionRebateBean initAddCondictionRebate = AddAgentProductCallService.InitAddCondictionRebate(addAgentProductBean,importAgentProductBean1, 5,30);
			AddAgentProductCallService.AddCondictionRebate(initAddCondictionRebate);
			
			//小店查询到商品规格
			
			ProductDetailsBean initGetProductDetails = AddAgentProductCallService.initGetProductDetails(AgentId1,
					StoreId, agentProductId1, true);
			ProductDetailsDto selectProductDetails = AddAgentProductCallService
					.GetProductDetailsCall(initGetProductDetails);
			List<String> catalogs = new ArrayList<>();
			selectProductDetails.getCatalogList().forEach(c -> {
				catalogs.add(c.getCatalogId());
			});

			Thread.sleep(5000);
			// 小店查询代理链
			queryagentpricechainBean.setCatalogIds(catalogs);
			queryagentpricechainBean.setUserId(StoreId);
			queryagentpricechainCall.setData(queryagentpricechainBean);
			queryagentpricechainCall.callService();
			Logger.verifyEquals("200", queryagentpricechainCall.getString("code"), "验证code");
			HashMap<String, List<CatalogLinkedMapDto>> result = queryagentpricechainCall.getResult();
			catalogs.forEach(p -> {
				result.get(p).forEach(x -> {
					if (x.getSellerId() == MchId) {
						Logger.verifyEquals(x.getFromParentPrice().doubleValue(),0.0,"验证fromParentPrice");
						Logger.verifyEquals(x.getFromParentPriceType(),0,"验证FromParentPriceType");
					} else if (x.getSellerId() == StoreId) {
						Logger.verifyEquals(x.getFromParentPrice().doubleValue(),20.0,"验证fromParentPrice");
						Logger.verifyEquals(x.getFromParentPriceType(),1,"验证FromParentPriceType");
						Logger.verifyEquals(x.getToChildPrice().setScale(1).doubleValue(),0.0,"验证toChildPrice");
					}
				});
			});
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QueryAgentPriceChain_18() {
		Logger.start(true,"商户->分销小店，条件分佣  品牌a 品类b 仓库c 佣金20和 品牌a  品类b佣金30  这个时候佣金20");
		try {
			//创建一个商户和分销小店
			Integer MchId = GodmchManageCallService.CreateGodMch();
			Integer StoreId = GodmchManageCallService.CreateStores(MchId, 10);
			createDepotBean bean=GodmchManageCallService.createDepot(MchId);
			List<mch_depot_info> selectDepotByDepotTitle = GodmchManageCallService.SelectDepotByDepotTitle(bean.getDepotTitle());
			// 给渠道商创建一个商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(MchId, "", true);
			addAgentProductBean.setDepotId(selectDepotByDepotTitle.get(0).getDepotId());
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			
			int addCondictionRebate = AddAgentProductCallService.AddCondictionRebate(addAgentProductBean, 1, 20);
			int addCondictionRebate1 = AddAgentProductCallService.AddCondictionRebate(addAgentProductBean, 2, 30);
			//小店查询到商品规格
			ProductDetailsBean initGetProductDetails = AddAgentProductCallService.initGetProductDetails(MchId,
					StoreId, productId, true);
			
			ProductDetailsDto selectProductDetails = AddAgentProductCallService
					.GetProductDetailsCall(initGetProductDetails);
			List<String> catalogs = new ArrayList<>();
			selectProductDetails.getCatalogList().forEach(c -> {
				catalogs.add(c.getCatalogId());
			});
			Thread.sleep(5000);
			// 小店查询代理链
			queryagentpricechainBean.setCatalogIds(catalogs);
			queryagentpricechainBean.setUserId(StoreId);
			queryagentpricechainCall.setData(queryagentpricechainBean);
			queryagentpricechainCall.callService();
			Logger.verifyEquals("200", queryagentpricechainCall.getString("code"), "验证code");
			HashMap<String, List<CatalogLinkedMapDto>> result = queryagentpricechainCall.getResult();
			catalogs.forEach(p -> {
				result.get(p).forEach(x -> {
					if (x.getSellerId() == MchId) {
						Logger.verifyEquals(x.getFromParentPrice().doubleValue(),0.0,"验证fromParentPrice");
						Logger.verifyEquals(x.getFromParentPriceType(),0,"验证FromParentPriceType");
					} else if (x.getSellerId() == StoreId) {
						Logger.verifyEquals(x.getFromParentPrice().doubleValue(),20.0,"验证fromParentPrice");
						Logger.verifyEquals(x.getFromParentPriceType(),1,"验证FromParentPriceType");
						Logger.verifyEquals(x.getToChildPrice().setScale(1).doubleValue(),0.0,"验证toChildPrice");
					}
					
				});
			});
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QueryAgentPriceChain_19() {
		Logger.start(true,"商户->分销小店，店铺分佣10，商品分佣20，条件分佣 30  这个时候佣金20");
		try {
			//创建一个商户和分销小店
			Integer MchId = GodmchManageCallService.CreateGodMch();
			Integer StoreId = GodmchManageCallService.CreateStores(MchId, 10);
			//创建商品，小店会继承
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(MchId, "", true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			Thread.sleep(5000);
			EditProductRebateBean initEditProductRebateBean = AddAgentProductCallService.initEditProductRebateBean(productId, StoreId, MchId, 20);
			AddAgentProductCallService.EditProductRebateBean(initEditProductRebateBean);
			int addCondictionRebate = AddAgentProductCallService.AddCondictionRebate(addAgentProductBean, 1, 30);
			int addCondictionRebate1 = AddAgentProductCallService.AddCondictionRebate(addAgentProductBean, 2, 40);
			//小店查询到商品规格
			ProductDetailsBean initGetProductDetails = AddAgentProductCallService.initGetProductDetails(MchId,
					StoreId, productId, true);
			ProductDetailsDto selectProductDetails = AddAgentProductCallService
					.GetProductDetailsCall(initGetProductDetails);
			List<String> catalogs = new ArrayList<>();
			selectProductDetails.getCatalogList().forEach(c -> {
				catalogs.add(c.getCatalogId());
			});
			Thread.sleep(5000);
			// 小店查询代理链
			queryagentpricechainBean.setCatalogIds(catalogs);
			queryagentpricechainBean.setUserId(StoreId);
			queryagentpricechainCall.setData(queryagentpricechainBean);
			queryagentpricechainCall.callService();
			Logger.verifyEquals("200", queryagentpricechainCall.getString("code"), "验证code");
			HashMap<String, List<CatalogLinkedMapDto>> result = queryagentpricechainCall.getResult();
			catalogs.forEach(p -> {
				result.get(p).forEach(x -> {
					if (x.getSellerId() == MchId) {
						Logger.verifyEquals(x.getFromParentPrice().doubleValue(),0.0,"验证fromParentPrice");
						Logger.verifyEquals(x.getFromParentPriceType(),0,"验证FromParentPriceType");
					} else if (x.getSellerId() == StoreId) {
						Logger.verifyEquals(x.getFromParentPrice().doubleValue(),20.0,"验证fromParentPrice");
						Logger.verifyEquals(x.getFromParentPriceType(),1,"验证FromParentPriceType");
						Logger.verifyEquals(x.getToChildPrice().setScale(1).doubleValue(),0.0,"验证toChildPrice");
					}
					
				});
			});
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QueryAgentPriceChain_20() {
		Logger.start(true,"商户->分销小店，店铺分佣10，商品分佣20， 这个时候佣金20");
		try {
			//创建一个商户和分销小店
			Integer MchId = GodmchManageCallService.CreateGodMch();
			Integer StoreId = GodmchManageCallService.CreateStores(MchId, 10);
			//创建商品，小店会继承
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(MchId, "", true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			Thread.sleep(5000);
			EditProductRebateBean initEditProductRebateBean = AddAgentProductCallService.initEditProductRebateBean(productId, StoreId, MchId, 20);
			AddAgentProductCallService.EditProductRebateBean(initEditProductRebateBean);
			//小店查询到商品规格
			ProductDetailsBean initGetProductDetails = AddAgentProductCallService.initGetProductDetails(MchId,
					StoreId, productId, true);
			ProductDetailsDto selectProductDetails = AddAgentProductCallService
					.GetProductDetailsCall(initGetProductDetails);
			List<String> catalogs = new ArrayList<>();
			selectProductDetails.getCatalogList().forEach(c -> {
				catalogs.add(c.getCatalogId());
			});
			Thread.sleep(5000);
			// 小店查询代理链
			queryagentpricechainBean.setCatalogIds(catalogs);
			queryagentpricechainBean.setUserId(StoreId);
			queryagentpricechainCall.setData(queryagentpricechainBean);
			queryagentpricechainCall.callService();
			Logger.verifyEquals("200", queryagentpricechainCall.getString("code"), "验证code");
			HashMap<String, List<CatalogLinkedMapDto>> result = queryagentpricechainCall.getResult();
			catalogs.forEach(p -> {
				result.get(p).forEach(x -> {
					if (x.getSellerId() == MchId) {
						Logger.verifyEquals(x.getFromParentPrice().doubleValue(),0.0,"验证fromParentPrice");
						Logger.verifyEquals(x.getFromParentPriceType(),0,"验证FromParentPriceType");
					} else if (x.getSellerId() == StoreId) {
						Logger.verifyEquals(x.getFromParentPrice().doubleValue(),20.0,"验证fromParentPrice");
						Logger.verifyEquals(x.getFromParentPriceType(),1,"验证FromParentPriceType");
						Logger.verifyEquals(x.getToChildPrice().setScale(1).doubleValue(),0.0,"验证toChildPrice");
					}
					
				});
			});
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QueryAgentPriceChain_21() {
		Logger.start(true,"商户->分销小店，店铺分佣10，条件分佣20， 这个时候佣金20");
		try {
			
			//创建一个商户和分销小店
			Integer MchId = GodmchManageCallService.CreateGodMch();
			Integer StoreId = GodmchManageCallService.CreateStores(MchId, 10);
			//创建商品，小店会继承
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(MchId, "", true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			Thread.sleep(5000);
			int addCondictionRebate = AddAgentProductCallService.AddCondictionRebate(addAgentProductBean, 2, 20);
			//小店查询到商品规格
			
			ProductDetailsBean initGetProductDetails = AddAgentProductCallService.initGetProductDetails(MchId,
					StoreId, productId, true);
			ProductDetailsDto selectProductDetails = AddAgentProductCallService
					.GetProductDetailsCall(initGetProductDetails);
			List<String> catalogs = new ArrayList<>();
			selectProductDetails.getCatalogList().forEach(c -> {
				catalogs.add(c.getCatalogId());
			});
			Thread.sleep(5000);
			// 小店查询代理链
			queryagentpricechainBean.setCatalogIds(catalogs);
			queryagentpricechainBean.setUserId(StoreId);
			queryagentpricechainCall.setData(queryagentpricechainBean);
			queryagentpricechainCall.callService();
			Logger.verifyEquals("200", queryagentpricechainCall.getString("code"), "验证code");
			HashMap<String, List<CatalogLinkedMapDto>> result = queryagentpricechainCall.getResult();
			catalogs.forEach(p -> {
				result.get(p).forEach(x -> {
					if (x.getSellerId() == MchId) {
						Logger.verifyEquals(x.getFromParentPrice().doubleValue(),0.0,"验证fromParentPrice");
						Logger.verifyEquals(x.getFromParentPriceType(),0,"验证FromParentPriceType");
					} else if (x.getSellerId() == StoreId) {
						Logger.verifyEquals(x.getFromParentPrice().doubleValue(),20.0,"验证fromParentPrice");
						Logger.verifyEquals(x.getFromParentPriceType(),1,"验证FromParentPriceType");
						Logger.verifyEquals(x.getToChildPrice().setScale(1).doubleValue(),0.0,"验证toChildPrice");
					}
					
				});
			});
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QueryAgentPriceChain_22() {
		Logger.start(true,"商户->分销小店，店铺分佣10，条件  20， 这个时候佣金20");
		try {
			//创建一个商户和分销小店
			Integer MchId = GodmchManageCallService.CreateGodMch();
			Integer StoreId = GodmchManageCallService.CreateStores(MchId, 10);
			//创建商品，小店会继承
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(MchId, "", true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			Thread.sleep(5000);
			
			int addCondictionRebate = AddAgentProductCallService.AddCondictionRebate(addAgentProductBean, 2, 20);
			//小店查询到商品规格
			ProductDetailsBean initGetProductDetails = AddAgentProductCallService.initGetProductDetails(MchId,
					StoreId, productId, true);
			ProductDetailsDto selectProductDetails = AddAgentProductCallService
					.GetProductDetailsCall(initGetProductDetails);
			List<String> catalogs = new ArrayList<>();
			selectProductDetails.getCatalogList().forEach(c -> {
				catalogs.add(c.getCatalogId());
			});
			
			Thread.sleep(5000);
			// 小店查询代理链
			queryagentpricechainBean.setCatalogIds(catalogs);
			queryagentpricechainBean.setUserId(StoreId);
			queryagentpricechainCall.setData(queryagentpricechainBean);
			queryagentpricechainCall.callService();
			Logger.verifyEquals("200", queryagentpricechainCall.getString("code"), "验证code");
			HashMap<String, List<CatalogLinkedMapDto>> result = queryagentpricechainCall.getResult();
			catalogs.forEach(p -> {
				result.get(p).forEach(x -> {
					if (x.getSellerId() == MchId) {
						Logger.verifyEquals(x.getFromParentPrice().doubleValue(),0.0,"验证fromParentPrice");
						Logger.verifyEquals(x.getFromParentPriceType(),0,"验证FromParentPriceType");
					} else if (x.getSellerId() == StoreId) {
						Logger.verifyEquals(x.getFromParentPrice().doubleValue(),20.0,"验证fromParentPrice");
						Logger.verifyEquals(x.getFromParentPriceType(),1,"验证FromParentPriceType");
						Logger.verifyEquals(x.getToChildPrice().setScale(1).doubleValue(),0.0,"验证toChildPrice");
					}
					
				});
			});
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QueryAgentPriceChain_23() {
		Logger.start(true,"商户->分销小店，条件分佣  品牌a 品类b 仓库c 佣金20和 品牌a  品类b佣金30  这个时候佣金20");
		try {
			//创建一个商户和分销小店
			Integer MchId = GodmchManageCallService.CreateGodMch();
			Integer StoreId = GodmchManageCallService.CreateStores(MchId, 10);
			createDepotBean bean=GodmchManageCallService.createDepot(MchId);
			List<mch_depot_info> selectDepotByDepotTitle = GodmchManageCallService.SelectDepotByDepotTitle(bean.getDepotTitle());
			// 给渠道商创建一个商品
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(MchId, "", true);
			addAgentProductBean.setDepotId(selectDepotByDepotTitle.get(0).getDepotId());
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			
			int addCondictionRebate = AddAgentProductCallService.AddCondictionRebate(addAgentProductBean, 1, 20);
			int addCondictionRebate1 = AddAgentProductCallService.AddCondictionRebate(addAgentProductBean, 2, 30);
			//小店查询到商品规格
			ProductDetailsBean initGetProductDetails = AddAgentProductCallService.initGetProductDetails(MchId,
					StoreId, productId, true);
			
			ProductDetailsDto selectProductDetails = AddAgentProductCallService
					.GetProductDetailsCall(initGetProductDetails);
			List<String> catalogs = new ArrayList<>();
			selectProductDetails.getCatalogList().forEach(c -> {
				catalogs.add(c.getCatalogId());
			});
			Thread.sleep(5000);
			// 小店查询代理链
			queryagentpricechainBean.setCatalogIds(catalogs);
			queryagentpricechainBean.setUserId(StoreId);
			queryagentpricechainCall.setData(queryagentpricechainBean);
			queryagentpricechainCall.callService();
			Logger.verifyEquals("200", queryagentpricechainCall.getString("code"), "验证code");
			HashMap<String, List<CatalogLinkedMapDto>> result = queryagentpricechainCall.getResult();
			catalogs.forEach(p -> {
				result.get(p).forEach(x -> {
					if (x.getSellerId() == MchId) {
						Logger.verifyEquals(x.getFromParentPrice().doubleValue(),0.0,"验证fromParentPrice");
						Logger.verifyEquals(x.getFromParentPriceType(),0,"验证FromParentPriceType");
					} else if (x.getSellerId() == StoreId) {
						Logger.verifyEquals(x.getFromParentPrice().doubleValue(),20.0,"验证fromParentPrice");
						Logger.verifyEquals(x.getFromParentPriceType(),1,"验证FromParentPriceType");
						Logger.verifyEquals(x.getToChildPrice().setScale(1).doubleValue(),0.0,"验证toChildPrice");
					}
					
				});
			});
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QueryAgentPriceChain_24() {
		Logger.start(true,"商户->分销小店，小店10分佣，指定商品的一个规格是20分佣   查询为20分佣");
		try {
			//创建一个商户和分销小店
			Integer MchId = GodmchManageCallService.CreateGodMch();
			Integer StoreId = GodmchManageCallService.CreateStores(MchId, 10);
			//创建商品，小店会继承
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(MchId, "", true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			Thread.sleep(5000);
			
			EditProductRebateBean initEditProductRebateBean = AddAgentProductCallService.initEditProductRebateBean(productId, StoreId, MchId, 20);
			initEditProductRebateBean.getCatalogRebateList().remove(0);
//			initEditProductRebateBean.getCatalogRebateList().get(0).setRebateValue(new BigDecimal(11));
			AddAgentProductCallService.EditProductRebateBean(initEditProductRebateBean);
			//小店查询到商品规格
			
			ProductDetailsBean initGetProductDetails = AddAgentProductCallService.initGetProductDetails(MchId,
					StoreId, productId, true);
			ProductDetailsDto selectProductDetails = AddAgentProductCallService
					.GetProductDetailsCall(initGetProductDetails);
			List<String> catalogs = new ArrayList<>();
			selectProductDetails.getCatalogList().forEach(c -> {
				catalogs.add(c.getCatalogId());
			});
			Thread.sleep(5000);
			
			// 小店查询代理链
			queryagentpricechainBean.setCatalogIds(catalogs);
			queryagentpricechainBean.setUserId(StoreId);
			queryagentpricechainCall.setData(queryagentpricechainBean);
			queryagentpricechainCall.callService();
			Logger.verifyEquals("200", queryagentpricechainCall.getString("code"), "验证code");
			HashMap<String, List<CatalogLinkedMapDto>> result = queryagentpricechainCall.getResult();
			String p = catalogs.get(1);
				result.get(p).forEach(x -> {
					if (x.getSellerId() == MchId) {
						Logger.verifyEquals(x.getFromParentPrice().doubleValue(),0.0,"验证fromParentPrice");
						Logger.verifyEquals(x.getFromParentPriceType(),0,"验证FromParentPriceType");
					} else if (x.getSellerId() == StoreId) {
						Logger.verifyEquals(x.getFromParentPrice().doubleValue(),20.0,"验证fromParentPrice");
						Logger.verifyEquals(x.getFromParentPriceType(),1,"验证FromParentPriceType");
						Logger.verifyEquals(x.getToChildPrice().setScale(1).doubleValue(),0.0,"验证toChildPrice");
					}
				});
				
					 p = catalogs.get(0);
						result.get(p).forEach(x -> {
							if (x.getSellerId() == MchId) {
								Logger.verifyEquals(x.getFromParentPrice().doubleValue(),0.0,"验证fromParentPrice");
								Logger.verifyEquals(x.getFromParentPriceType(),0,"验证FromParentPriceType");
							} else if (x.getSellerId() == StoreId) {
								Logger.verifyEquals(x.getFromParentPrice().doubleValue(),10.0,"验证fromParentPrice");
								Logger.verifyEquals(x.getFromParentPriceType(),1,"验证FromParentPriceType");
								Logger.verifyEquals(x.getToChildPrice().setScale(1).doubleValue(),0.0,"验证toChildPrice");
							}
							
			});
				
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	

}